﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using DBTools.DBUpdate.Comm;


namespace DBTools.DBUpdate
{
    public partial class SettingForm : FormBase
    {
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        public SettingForm()
        {
            InitializeComponent();
        }

        private void SettingForm_Load(object sender, EventArgs e)
        {
            //固定窗口大小
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetData();
        }

        private void button_Canel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button_OK_Click(object sender, EventArgs e)
        {
            SaveData();
            MessageBox.Show("更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
        public void SaveData()
        {
            Set.DbServerConnectionString = string.Format("server={0};uid={1};pwd={2};database=master",
                textBox_server.Text, 
                textBox_username.Text,
                textBox_password.Text);
            Set.DbConnectionTimeOut = int.Parse(textBox_TimeOut.Text);
            Set.ServerIp = textBox_server.Text;
            Set.UserName = textBox_username.Text;
            Set.PassWord = textBox_password.Text;
        }
        public void SetData()
        {

        }
    }
}
